package com.ningxun.rms.web.controller.bus;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import com.ningxun.rms.common.core.controller.BaseController;
import com.ningxun.rms.common.core.domain.AjaxResult;
import com.ningxun.rms.common.core.page.TableDataInfo;
import com.ningxun.rms.common.utils.poi.ExcelUtil;
import com.ningxun.rms.signup.domain.BusSignup;
import com.ningxun.rms.signup.domain.vo.BusSignupWithRequireVO;
import com.ningxun.rms.signup.service.IBusSignupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 报名信息管理Controller
 * 
 * @author rms
 * @date 2025-07-15
 */
@RestController
@RequestMapping("/admin/signup")
public class BusRequireSignUpController extends BaseController
{
    @Autowired
    private IBusSignupService busSignupService;

    /**
     * 查询报名信息与需求信息联查列表
     */
    @GetMapping("/list")
    public TableDataInfo selectSignupWithRequireList(BusSignup busSignup)
    {
        startPage();
        List<BusSignupWithRequireVO> list = busSignupService.selectSignupWithRequireList(busSignup);
        return getDataTable(list);
    }

    /**
     * 导出报名信息数据
     */
    @GetMapping("/export")
    public void export(BusSignup busSignup, HttpServletResponse response)
    {
        try {
            List<BusSignupWithRequireVO> list = busSignupService.exportSignupData(busSignup);
            ExcelUtil<BusSignupWithRequireVO> util = new ExcelUtil<BusSignupWithRequireVO>(BusSignupWithRequireVO.class);
            util.exportExcel(response, list, "报名数据");
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("导出失败: " + e.getMessage());
        }
    }
}
